package wiki.hitime.stl.daq.bean.bo;

import lombok.*;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhangdaoping
 * @create 2019-07-23 11:15
 */
@Data
@Builder
@AllArgsConstructor
@RequiredArgsConstructor
public class DataMsgParamBO {

    /**
     * 执行日期时间
     */
    private String executeDate;

    /**
     * 执行规则名称
     */
    private String executeRuleName;

    /**
     * 检查摘要
     */
    private String checkSummary;

    /**
     * 检查结果
     */
    private String checkResult;

    /**
     * 第一个数据
     */
    private String firstData;

    /**
     * 最后一个数据
     */
    private String lastData;


    public List<String> listMsgKey() {
        List<String> msgKeys = new ArrayList<>();
        for (Field field : DataMsgParamBO.class.getDeclaredFields()) {
            msgKeys.add(field.getName());
        }
        return msgKeys;
    }

    public Map<String, String> loadParamMap() {
        Map<String, String> paramMap = new HashMap<>();
        for (Field field : DataMsgParamBO.class.getDeclaredFields()) {
            field.setAccessible(true);
            try {
                paramMap.put(field.getName(), field.get(this).toString());
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        return paramMap;
    }

}
